//
//  GasConfirmAlertView.m
//  NtoccDriverNew
//
//  Created by niyongsheng on 2022/10/18.
//  Copyright © 2022 GCY. All rights reserved.
//

#import "GasConfirmAlertView.h"

@interface GasConfirmAlertView ()
@property (weak, nonatomic) IBOutlet UIImageView *iconIV;
@property (weak, nonatomic) IBOutlet UILabel *titleL;
@property (weak, nonatomic) IBOutlet UIButton *confirmBtn;

@end

@implementation GasConfirmAlertView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        NSBundle *bundle = [NSBundle bundleForClass:[self class]];
        UINib *nib = [UINib nibWithNibName:NSStringFromClass([self class])
                                    bundle:bundle];
        
        UIView *view = [nib instantiateWithOwner:self options:nil][0];
        
        view.frame = self.bounds;
        view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        
        [self addSubview:view];
        [self setupView];
    }
    return self;
}

- (void)setupView {
    ViewRadius(self, 10)
    ViewRadius(_confirmBtn, 5)
}

- (void)setIsSuccess:(BOOL)isSuccess {
    _isSuccess = isSuccess;
    
    if (isSuccess) {
        [_iconIV setImage:[UIImage imageNamed:@"gas_icon_success"]];
        _titleL.text = @"加油成功，请离场";
    } else {
        [_iconIV setImage:[UIImage imageNamed:@"gas_icon_fail"]];
        _titleL.text = @"加油失败，请使用现金";
    }
}

- (void)setMsg:(NSString *)msg {
    _msg = msg;
    
    _titleL.text = msg;
}

- (IBAction)confirmBtnOnclicked:(UIButton *)sender {
    if (_block) {
        self.block(0);
    }
}

@end
